import ajax from '../../js/ajax.js';
import md5 from '../../libs/md5.min.js';

let txtUsername=document.getElementById('txtUsername');
let txtPwd=document.getElementById('txtPwd');
let btnLogin=document.getElementById('btnLogin');

btnLogin.addEventListener('click',()=>{
  let user={
    username:txtUsername.value,
    password:md5.hash(txtPwd.value),
  };
  ajax.send('/user/auth/login',user,(data)=>{
  if(!data.success){
    return;
  }
   //成功跳转
  location.href='./ym.html';
  });
});


//#region 公用的轻提示对话框

let liveToast = document.getElementById('liveToast');
let liveToastMessing = document.querySelector('#liveToast .toast-body');

const toast = new bootstrap.Toast(liveToast);

function showToast(message) {
  liveToastMessing.innerHTML = message;
  toast.show();
}
//#endregion
